<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<script type="text/javascript">
	$(function() {
		$('#user_login_loginForm input').bind('keyup', function(event) {
			/* 增加回车提交登录功能 */
			if (event.keyCode == '13') {
				login();
			}
		});
		
		window.setTimeout(function(){
			$('#user_login_loginForm input[name=name]').focus();
		}, 0);
	});

	function login() {
		if ($('#user_login_loginForm').form('validate')) {
			$.ajax({
				type : 'POST',
				url : '${pageContext.request.contextPath}/userAction!login.action',
				data : $('#user_login_loginForm').serialize(),
				dataType : 'json',
				success : function(obj) {
					if (obj.success) {
						$('#user_login_loginDialog').dialog('close');
					}

					$.messager.show({
						title : '提示',
						msg : obj.msg
					});
				}
			});
		}
	}
</script>
<div id="user_login_loginDialog" class="easyui-dialog" data-options="title: '登录', modal:true, closable: false, buttons:[{
				text:'注册',
				iconCls:'icon-edit',
				handler:function(){
					$('#user_reg_regDialog').dialog('open');
					$('#user_reg_regForm').form('clear');
				}
			},{
				text:'登录',
				iconCls:'icon-help',
				handler:login
			}]">
	<form id="user_login_loginForm" method="post">
		<table>
			<tr>
				<th>用户名</th>
				<td><input name="name" class="easyui-validatebox" data-options="required:true, missingMessage: '用户名不能为空'" />
				</td>
			</tr>
			<tr>
				<th>密码</th>
				<td><input type="password" name="pwd" class="easyui-validatebox" data-options="required:true, missingMessage: '密码必填'" />
				</td>
			</tr>
		</table>
	</form>
</div>